```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java并发编程指南 | 并发容器与工具类详解</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #1a1a1a;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            border-left: 4px solid #667eea;
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .feature-icon {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        .mermaid-tooltip {
            position: absolute;
            padding: 8px;
            background-color: #fff;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            z-index: 100;
            opacity: 0;
            transition: opacity 0.3s;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6">Java并发编程指南</h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">探索并发容器与工具类的强大功能</p>
            <div class="flex justify-center">
                <div class="w-full md:w-3/4 bg-white bg-opacity-10 backdrop-filter backdrop-blur-sm rounded-xl p-6">
                    <p class="text-lg">在并发编程中，Java提供了一系列专门的并发容器和工具类，帮助开发者有效管理并发操作，避免多线程环境中的常见问题（如竞态条件、死锁等），并显著提升程序的并发性能。这些工具广泛应用于并发控制、线程间通信和任务调度等关键场景。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-6xl px-4 md:px-0 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-6 md:p-8">
                <h2 class="text-3xl font-bold mb-6 text-gray-800 border-b pb-4">并发编程核心概念</h2>
                <p class="text-gray-700 mb-6">现代Java应用需要充分利用多核处理器的计算能力，而并发编程是实现这一目标的关键。Java并发工具包(java.util.concurrent)提供了高效、线程安全的容器和实用的同步工具，让开发者能够构建高性能的并发应用。</p>
                
                <!-- Mermaid Diagram -->
                <div class="my-8 p-6 bg-gray-50 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4 text-gray-700">并发工具类关系图</h3>
                    <div class="mermaid">
                        graph TD
                            A[Java并发工具] --> B[并发容器]
                            A --> C[并发工具类]
                            B --> B1[ConcurrentHashMap]
                            B --> B2[CopyOnWriteArrayList]
                            B --> B3[BlockingQueue]
                            B --> B4[ConcurrentLinkedQueue]
                            C --> C1[Executor框架]
                            C --> C2[CountDownLatch]
                            C --> C3[CyclicBarrier]
                            C --> C4[Semaphore]
                    </div>
                </div>
            </div>
        </section>

        <!-- Concurrent Collections -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="bg-indigo-600 text-white px-6 py-4">
                    <h2 class="text-2xl font-bold flex items-center">
                        <i class="fas fa-boxes mr-3"></i>
                        并发容器 (Concurrent Collections)
                    </h2>
                </div>
                <div class="p-6 md:p-8">
                    <p class="text-gray-700 mb-8">并发容器专为多线程环境设计，提供了线程安全的操作，通常比传统的同步容器（如Vector、Hashtable）具有更高的性能。它们通过智能的锁策略或无锁算法实现高效的并发访问。</p>
                    
                    <!-- ConcurrentHashMap -->
                    <div class="mb-12 card-hover">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mr-4">
                                <div class="feature-icon text-4xl">
                                    <i class="fas fa-map-marked-alt"></i>
                                </div>
                            </div>
                            <div>
                                <h3 class="text-2xl font-bold text-gray-800 mb-3">ConcurrentHashMap</h3>
                                <p class="text-gray-700 mb-4">一种线程安全的哈希表实现，允许多个线程并发地访问数据，通过分段锁减少锁竞争，提高并发性能。</p>
                                
                                <div class="bg-indigo-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-indigo-700 mb-2 flex items-center">
                                        <i class="fas fa-lightbulb mr-2"></i>
                                        原理分析
                                    </h4>
                                    <p class="text-gray-700">ConcurrentHashMap通过将数据分为多个段，每个段有独立的锁。不同线程可以在不同段上执行操作，提高了并发性能。写操作会锁住相应段，而读取操作不会阻塞其他线程的读取。</p>
                                </div>
                                
                                <div class="bg-green-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-green-700 mb-2 flex items-center">
                                        <i class="fas fa-tasks mr-2"></i>
                                        应用场景
                                    </h4>
                                    <p class="text-gray-700">适用于高并发的读取和少量写入操作，如缓存系统、计数器等。</p>
                                </div>
                                
                                <div class="code-block text-gray-200 p-4 rounded-lg overflow-x-auto">
                                    <pre><code class="language-java">ConcurrentHashMap&lt;String, Integer&gt; map = new ConcurrentHashMap&lt;&gt;();
map.put("A", 1);
map.put("B", 2);
map.computeIfAbsent("C", key -> 3);</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- CopyOnWriteArrayList -->
                    <div class="mb-12 card-hover">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mr-4">
                                <div class="feature-icon text-4xl">
                                    <i class="fas fa-copy"></i>
                                </div>
                            </div>
                            <div>
                                <h3 class="text-2xl font-bold text-gray-800 mb-3">CopyOnWriteArrayList</h3>
                                <p class="text-gray-700 mb-4">线程安全的动态数组实现，通过复制整个底层数组来避免线程间的竞争，适合读多写少的场景。</p>
                                
                                <div class="bg-indigo-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-indigo-700 mb-2 flex items-center">
                                        <i class="fas fa-lightbulb mr-2"></i>
                                        原理分析
                                    </h4>
                                    <p class="text-gray-700">所有的写操作都会创建原数组的副本，在副本上进行修改，最后将修改后的副本替换原始数组。这保证了读取操作不受锁的影响，实现高效的并发读取。</p>
                                </div>
                                
                                <div class="bg-green-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-green-700 mb-2 flex items-center">
                                        <i class="fas fa-tasks mr-2"></i>
                                        应用场景
                                    </h4>
                                    <p class="text-gray-700">适用于读多写少的场景，如实现多线程环境下的事件监听器。</p>
                                </div>
                                
                                <div class="code-block text-gray-200 p-4 rounded-lg overflow-x-auto">
                                    <pre><code class="language-java">CopyOnWriteArrayList&lt;String&gt; list = new CopyOnWriteArrayList&lt;&gt;();
list.add("Item1");
list.add("Item2");
list.forEach(System.out::println); // 高效的并发读取</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- BlockingQueue -->
                    <div class="mb-12 card-hover">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mr-4">
                                <div class="feature-icon text-4xl">
                                    <i class="fas fa-exchange-alt"></i>
                                </div>
                            </div>
                            <div>
                                <h3 class="text-2xl font-bold text-gray-800 mb-3">BlockingQueue</h3>
                                <p class="text-gray-700 mb-4">线程安全的队列，提供阻塞操作，在生产者-消费者模式下非常有用。常见实现有ArrayBlockingQueue、LinkedBlockingQueue等。</p>
                                
                                <div class="bg-indigo-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-indigo-700 mb-2 flex items-center">
                                        <i class="fas fa-lightbulb mr-2"></i>
                                        原理分析
                                    </h4>
                                    <p class="text-gray-700">主要用于线程间通信，提供阻塞的入队和出队操作。当队列为空时，消费线程被阻塞；当队列满时，生产者线程被阻塞。避免线程因忙等问题浪费CPU资源。</p>
                                </div>
                                
                                <div class="bg-green-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-green-700 mb-2 flex items-center">
                                        <i class="fas fa-tasks mr-2"></i>
                                        应用场景
                                    </h4>
                                    <p class="text-gray-700">常用于生产者-消费者模型、任务队列、线程池等。</p>
                                </div>
                                
                                <div class="code-block text-gray-200 p-4 rounded-lg overflow-x-auto">
                                    <pre><code class="language-java">BlockingQueue&lt;Integer&gt; queue = new ArrayBlockingQueue&lt;&gt;(10);
queue.put(1); // 阻塞直到队列有空间
int value = queue.take(); // 阻塞直到队列有元素</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- ConcurrentLinkedQueue -->
                    <div class="card-hover">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mr-4">
                                <div class="feature-icon text-4xl">
                                    <i class="fas fa-project-diagram"></i>
                                </div>
                            </div>
                            <div>
                                <h3 class="text-2xl font-bold text-gray-800 mb-3">ConcurrentLinkedQueue</h3>
                                <p class="text-gray-700 mb-4">线程安全的无界队列，采用非阻塞方式操作，基于CAS算法保证并发安全，适用于高并发场景。</p>
                                
                                <div class="bg-indigo-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-indigo-700 mb-2 flex items-center">
                                        <i class="fas fa-lightbulb mr-2"></i>
                                        原理分析
                                    </h4>
                                    <p class="text-gray-700">使用无锁的CAS算法保证线程安全，避免了锁的开销，非常高效。是一个FIFO队列，提供入队、出队操作。</p>
                                </div>
                                
                                <div class="bg-green-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-green-700 mb-2 flex items-center">
                                        <i class="fas fa-tasks mr-2"></i>
                                        应用场景
                                    </h4>
                                    <p class="text-gray-700">适用于高吞吐量的队列操作，如消息队列、任务调度等。</p>
                                </div>
                                
                                <div class="code-block text-gray-200 p-4 rounded-lg overflow-x-auto">
                                    <pre><code class="language-java">ConcurrentLinkedQueue&lt;String&gt; queue = new ConcurrentLinkedQueue&lt;&gt;();
queue.offer("Item1");
String item = queue.poll(); // 非阻塞的出队操作</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Concurrency Utilities -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="bg-purple-600 text-white px-6 py-4">
                    <h2 class="text-2xl font-bold flex items-center">
                        <i class="fas fa-tools mr-3"></i>
                        并发工具类 (Concurrency Utilities)
                    </h2>
                </div>
                <div class="p-6 md:p-8">
                    <p class="text-gray-700 mb-8">并发工具类提供高效并发操作的方法，帮助开发者简化并发控制、提高系统性能，并解决并发编程中的常见问题。这些工具让复杂的线程同步变得简单而优雅。</p>
                    
                    <!-- Executor Framework -->
                    <div class="mb-12 card-hover">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mr-4">
                                <div class="feature-icon text-4xl">
                                    <i class="fas fa-server"></i>
                                </div>
                            </div>
                            <div>
                                <h3 class="text-2xl font-bold text-gray-800 mb-3">Executor Framework</h3>
                                <p class="text-gray-700 mb-4">提供将任务提交给线程池执行的机制，有效管理线程池和任务调度，避免直接使用Thread类的复杂性。</p>
                                
                                <div class="bg-purple-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-purple-700 mb-2 flex items-center">
                                        <i class="fas fa-lightbulb mr-2"></i>
                                        原理分析
                                    </h4>
                                    <p class="text-gray-700">将线程池的创建、任务的提交和执行分离开来。开发者只需提交任务，无需关心底层线程管理。常见实现有ThreadPoolExecutor、ScheduledThreadPoolExecutor等。</p>
                                </div>
                                
                                <div class="bg-green-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-green-700 mb-2 flex items-center">
                                        <i class="fas fa-tasks mr-2"></i>
                                        应用场景
                                    </h4>
                                    <p class="text-gray-700">适用于执行大量异步任务，如并发文件处理、网络请求等。</p>
                                </div>
                                
                                <div class="code-block text-gray-200 p-4 rounded-lg overflow-x-auto">
                                    <pre><code class="language-java">ExecutorService executor = Executors.newFixedThreadPool(10);
executor.submit(() -> {
    System.out.println("Task executed by thread: " + 
        Thread.currentThread().getName());
});</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- CountDownLatch -->
                    <div class="mb-12 card-hover">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mr-4">
                                <div class="feature-icon text-4xl">
                                    <i class="fas fa-hourglass-start"></i>
                                </div>
                            </div>
                            <div>
                                <h3 class="text-2xl font-bold text-gray-800 mb-3">CountDownLatch</h3>
                                <p class="text-gray-700 mb-4">同步工具类，控制一个或多个线程等待直到其他线程完成操作。通过计数器管理，计数器为0时等待线程继续执行。</p>
                                
                                <div class="bg-purple-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-purple-700 mb-2 flex items-center">
                                        <i class="fas fa-lightbulb mr-2"></i>
                                        原理分析
                                    </h4>
                                    <p class="text-gray-700">计数器初始化为指定值，调用countDown()使计数器减少。当计数器减至0时，所有调用await()的线程都会被释放。</p>
                                </div>
                                
                                <div class="bg-green-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-green-700 mb-2 flex items-center">
                                        <i class="fas fa-tasks mr-2"></i>
                                        应用场景
                                    </h4>
                                    <p class="text-gray-700">适用于并发任务的启动或完成时控制线程同步，如并行任务协调、多线程等待等。</p>
                                </div>
                                
                                <div class="code-block text-gray-200 p-4 rounded-lg overflow-x-auto">
                                    <pre><code class="language-java">CountDownLatch latch = new CountDownLatch(3);
new Thread(() -> {
    // 执行任务
    latch.countDown();  // 计数器减一
}).start();
latch.await();  // 等待计数器变为0</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- CyclicBarrier -->
                    <div class="mb-12 card-hover">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mr-4">
                                <div class="feature-icon text-4xl">
                                    <i class="fas fa-sync-alt"></i>
                                </div>
                            </div>
                            <div>
                                <h3 class="text-2xl font-bold text-gray-800 mb-3">CyclicBarrier</h3>
                                <p class="text-gray-700 mb-4">允许一组线程相互等待，直到所有线程都到达同步点。所有线程到达后一起继续执行。</p>
                                
                                <div class="bg-purple-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-purple-700 mb-2 flex items-center">
                                        <i class="fas fa-lightbulb mr-2"></i>
                                        原理分析
                                    </h4>
                                    <p class="text-gray-700">维护一个计数器，每个线程执行到指定位置时调用await()，直到所有线程都调用了await()，然后计数器重置，所有线程一起继续执行。</p>
                                </div>
                                
                                <div class="bg-green-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-green-700 mb-2 flex items-center">
                                        <i class="fas fa-tasks mr-2"></i>
                                        应用场景
                                    </h4>
                                    <p class="text-gray-700">适用于一组线程协同工作，直到所有线程完成一个阶段时再继续执行，如并行计算中的阶段性同步。</p>
                                </div>
                                
                                <div class="code-block text-gray-200 p-4 rounded-lg overflow-x-auto">
                                    <pre><code class="language-java">CyclicBarrier barrier = new CyclicBarrier(3, () -> {
    System.out.println("All threads reached barrier");
});
new Thread(() -> {
    try {
        barrier.await();
    } catch (InterruptedException | BrokenBarrierException e) {
        e.printStackTrace();
    }
}).start();</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Semaphore -->
                    <div class="card-hover">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mr-4">
                                <div class="feature-icon text-4xl">
                                    <i class="fas fa-traffic-light"></i>
                                </div>
                            </div>
                            <div>
                                <h3 class="text-2xl font-bold text-gray-800 mb-3">Semaphore</h3>
                                <p class="text-gray-700 mb-4">计数信号量，用于控制访问资源的线程数量。限制同时访问某个资源的线程数，避免资源耗尽或过度并发。</p>
                                
                                <div class="bg-purple-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-purple-700 mb-2 flex items-center">
                                        <i class="fas fa-lightbulb mr-2"></i>
                                        原理分析
                                    </h4>
                                    <p class="text-gray-700">维护一个计数器表示可用资源数量。获取信号量时计数器减一；释放信号量时加一。计数器为0时线程被阻塞，直到有可用信号量。</p>
                                </div>
                                
                                <div class="bg-green-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-semibold text-green-700 mb-2 flex items-center">
                                        <i class="fas fa-tasks mr-2"></i>
                                        应用场景
                                    </h4>
                                    <p class="text-gray-700">适用于限制资源的并发访问，如数据库连接池、限流器等。</p>
                                </div>
                                
                                <div class="code-block text-gray-200 p-4 rounded-lg overflow-x-auto">
                                    <pre><code class="language-java">Semaphore semaphore = new Semaphore(2);  // 允许最多2个线程访问
semaphore.acquire();  // 获取信号量
// 执行任务
semaphore.release();  // 释放信号量</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary -->
        <section class="bg-gradient-to-r from-indigo-500 to-purple-600 text-white rounded-xl shadow-lg p-8 mb-16">
            <h2 class="text-2xl md:text-3xl font-bold mb-6">Java并发编程要点总结</h2>
            <div class="grid md:grid-cols-2 gap-6">
                <div class="bg-white bg-opacity-10 p-6 rounded-lg backdrop-filter backdrop-blur-sm">
                    <h3 class="text-xl font-semibold mb-3">并发容器选择指南</h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1 text-green-300"></i>
                            <span>高并发读写：选择ConcurrentHashMap</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1 text-green-300"></i>
                            <span>读多写少：选择CopyOnWriteArrayList</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1 text-green-300"></i>
                            <span>生产者-消费者模式：选择BlockingQueue</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1 text-green-300"></i>
                            <span>高吞吐量无界队列：选择ConcurrentLinkedQueue</span>
                        </li>
                    </ul>
                </div>
                <div class="bg-white bg-opacity-10 p-6 rounded-lg backdrop-filter backdrop-blur-sm">
                    <h3 class="text-xl font-semibold mb-3">并发工具使用场景</h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1 text-green-300"></i>
                            <span>任务执行管理：使用Executor框架</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1 text-green-300"></i>
                            <span>线程同步等待：使用CountDownLatch</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1 text-green-300"></i>
                            <span>多阶段同步：使用CyclicBarrier</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1 text-green-300"></i>
                            <span>资源访问控制：使用Semaphore</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="container mx-auto max-w-6xl px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-semibold text-white">技术小馆</h3>
                    <p class="mt-1">专业的编程技术分享平台</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-indigo-300 hover:text-white transition-colors duration-300 flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // Add hover effect to mermaid nodes
        document.addEventListener('DOMContentLoaded', function() {
            const mermaidElements = document.querySelectorAll('.mermaid .node');
            mermaidElements.forEach(node => {
                node.style.cursor = 'pointer';
                node.addEventListener('mouseenter', function() {
                    const tooltip = document.createElement('div');
                    tooltip.className = 'mermaid-tooltip';
                    tooltip.textContent = this.querySelector('div span').textContent;
                    document.body.appendChild(tooltip);
                    
                    const rect = this.getBoundingClientRect();
                    tooltip.style.left = `${rect.left + window.scrollX}px`;
                    tooltip.style.top = `${rect.bottom + window.scrollY}px`;
                    tooltip.style.opacity = '1';
                    
                    this._tooltip = tooltip;
                });
                
                node.addEventListener('mouseleave', function() {
                    if (this._tooltip) {
                        document.body.removeChild(this._tooltip);
                        this._tooltip = null;
                    }
                });
            });
        });
    </script>
</body>
</html>
```